package com.shushan.home.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @ClassName: HomeIndexBean
 * @Desciption: //TODO
 * @author: yichaohua
 * @date: 2018-12-08
 */
public class HomeIndexBean extends NetBaseBean {

    public int znlx;//0、没有智能练习 1、有智能练习
    public int priority_completion;//0、优先智能练习开关->关,1、打开
    private List<BannerDataBean> bannerDataBeanList = new ArrayList<BannerDataBean>();
    private List<BannerDataBean> noticeDataBeanList = new ArrayList<BannerDataBean>();
    private List<ExerciseBean> exerciseBeanList = new ArrayList<ExerciseBean>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        znlx = jsonObject.optInt("znlx",0);
        priority_completion = jsonObject.optInt("priority_completion",0);

        JSONArray bannerArray = jsonObject.optJSONArray("banner");
        if(bannerArray != null){
            for (int i = 0;i < bannerArray.length();i++){
                JSONObject object = bannerArray.optJSONObject(i);
                BannerDataBean bannerDataBean = new BannerDataBean();
                bannerDataBean.initByJson(object);
                bannerDataBeanList.add(bannerDataBean);
            }
        }

        JSONArray noticeArray = jsonObject.optJSONArray("notice");
        if(noticeArray != null){
            for (int i = 0;i < noticeArray.length();i++){
                JSONObject object = noticeArray.optJSONObject(i);
                BannerDataBean noticeDataBean = new BannerDataBean();
                noticeDataBean.initByJson(object);
                noticeDataBeanList.add(noticeDataBean);
            }
        }

        JSONArray exerciseArray = jsonObject.optJSONArray("list");
        if(exerciseArray != null){
            for (int i = 0;i < exerciseArray.length();i++){
                JSONObject object = exerciseArray.optJSONObject(i);
                ExerciseBean exerciseBean = new ExerciseBean();
                exerciseBean.initByJson(object);
                exerciseBeanList.add(exerciseBean);
            }

            Collections.sort(exerciseBeanList);
        }
    }

    public List<BannerDataBean> getBannerDataBeanList() {
        return bannerDataBeanList;
    }

    public void setBannerDataBeanList(List<BannerDataBean> bannerDataBeanList) {
        this.bannerDataBeanList = bannerDataBeanList;
    }

    public List<BannerDataBean> getNoticeDataBeanList() {
        return noticeDataBeanList;
    }

    public void setNoticeDataBeanList(List<BannerDataBean> noticeDataBeanList) {
        this.noticeDataBeanList = noticeDataBeanList;
    }

    public List<ExerciseBean> getExerciseBeanList() {
        return exerciseBeanList;
    }

    public void setExerciseBeanList(List<ExerciseBean> exerciseBeanList) {
        this.exerciseBeanList = exerciseBeanList;
    }
}
